package com.budwk.app.sqfwV2.enums;

import com.budwk.app.sqfwDoc.codeGenerator.excelGenerate.BaseTemplateExcelGenerator;
import com.budwk.app.sqfwV2.generator.wasteCategory.excel.RefuseClassifyRecGenerator;
import com.budwk.app.sqfwV2.generator.wasteCategory.excel.RefuseClassifyYuHongGenerator;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 垃圾分类
 */
@Getter
public enum WasteCategoryFileServiceEnum {

    ONE_EXCEL("waste_category_rec_excel", new RefuseClassifyRecGenerator(), "sqfwV2/wasteCategory/refuseClassifyRec.xlsx", "","垃圾分类清单台账", "/preview/ws/ws_other_excel.png", "台账"),
    TWO_EXCEL("waste_category_rec_yuhong_excel", new RefuseClassifyYuHongGenerator(), "sqfwV2/wasteCategory/refuseClassifyYuHongSQ.xlsx", "","垃圾分类清单台账", "/preview/ws/ws_yuhong_excel.png", "台账"),

    ONE_PDF("waste_category_rec_doc", null, "sqfwV2/wasteCategory/refuseClassify.docx", "sqfwV2/wasteCategory/template/refuseClassifyTemplate.docx","【垃圾分类巡查】合集", "/preview/ws/ws_other_pdf.png", ""),
    TWO_PDF("waste_category_rec_yuhong_doc", null, "sqfwV2/wasteCategory/refuseClassifyYuHongSQ.docx", "","【垃圾分类巡查】合集", "/preview/ws/wx_yuhong_pdf.png", "");

    private final String code;

    private final BaseTemplateExcelGenerator service;

    private final String filePath;
    private final String fileTemplatePath;

    private final String fileName;

    private final String previewImage;

    private final String label;  // 标签

    WasteCategoryFileServiceEnum(String code, BaseTemplateExcelGenerator service, String filePath, String fileTemplatePath, String fileName, String previewImage, String label) {
        this.code = code;
        this.service = service;
        this.filePath = filePath;
        this.fileTemplatePath = fileTemplatePath;
        this.fileName = fileName;
        this.previewImage = previewImage;
        this.label = label;
    }

    public static List<WasteCategoryFileServiceEnum> listExcels() {
        return List.of(ONE_EXCEL, TWO_EXCEL);
    }

    public static List<WasteCategoryFileServiceEnum> listPdfs() {
        return List.of(ONE_PDF, TWO_PDF);
    }

    public static String getFileName(String code) {
        String fileName = Arrays.asList(WasteCategoryFileServiceEnum.values())
                .stream()
                .filter(e -> code.equals(e.getCode()))
                .collect(Collectors.toList())
                .get(0)
                .getFileName();
        return fileName;
    }

    public static WasteCategoryFileServiceEnum getEnums(String code) {
        WasteCategoryFileServiceEnum wasteCategoryFileServiceEnum = Arrays.asList(WasteCategoryFileServiceEnum.values())
                .stream()
                .filter(e -> code.equals(e.getCode()))
                .collect(Collectors.toList())
                .get(0);
        return wasteCategoryFileServiceEnum;
    }
}
